package com.yb.oldlearning;

public class Joiner extends Thread{
	private Sleeper sleeper;
	public Joiner(String name,Sleeper sleeper){
		super(name);
		this.sleeper = sleeper;
		start();
	}
	
	public void run(){
		try {
			sleeper.join();
		} catch (InterruptedException e) {
			System.out.println("interrupted");
		}
		System.out.println(getName() + " join completed");
	}
	
	public static void main(String[] args) {
		Sleeper 
			sleeperA = new Sleeper("sleeperA", 1500),
			sleeperB = new Sleeper("sleeperB",1500);
		Joiner 
			joinerA = new Joiner("joinerA", sleeperA),
			joinerB = new Joiner("joinerB", sleeperB);
		sleeperB.interrupt();
	}
}

